package gagak.framework.web.param;


/*
 * @program: ce
 * @description: 参数
 * @author: houhong
 * @create: 2022-11-23 23:00
 */
public class Parameter {

    /*
     * 形参名
     */
    private final String name;
    //修饰符合
    private final int modifiers;

    /*
     * 形参索引
     */
    private final int index;


    public Parameter(String name,
                     int modifiers,
                     int index) {
        this.name = name;
        this.modifiers = modifiers;
        this.index = index;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj instanceof Parameter) {
            Parameter other = (Parameter) obj;
            return (other.index == index);
        }
        return false;
    }

    @Override
    public int hashCode() {
        return this.name.hashCode() + index;
    }


    public String getName() {

        if (name == null || name.equals("")) {
            return "arg" + index;
        } else {
            return name;
        }
    }

    String getRealName() {
        return name;
    }

}